<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2016/11/28
 * Time: 10:02
 */

$ar1 = array(10, 100, 100, 0);
$ar2 = array(1, 3, 2, 4);
array_multisort($ar1, $ar2);

var_dump($ar1);
var_dump($ar2);
//In this example, after sorting, the first array will contain 0, 10, 100, 100. The second array will contain 4, 1, 2, 3. The entries in the second array corresponding to the identical entries in the first array (100 and 100) were sorted as well.
$a = [4,3,2,1];
$b = [1,2,3,4];
array_multisort($a,$b);
var_dump($a);
var_dump($b);


//==================================
//    what
//==================================
$ar = array(
	array("010", 11, 100, 100, "a"),
	array(   1,  2, "2",   3,   1)
);
array_multisort($ar[0], SORT_ASC, SORT_STRING,
	$ar[1], SORT_NUMERIC, SORT_DESC);
var_dump($ar);

//====================================
// 对数据库结果进行排序
//====================================

$data[] = array('volume' => 67, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 1);
$data[] = array('volume' => 85, 'edition' => 6);
$data[] = array('volume' => 98, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 6);
$data[] = array('volume' => 67, 'edition' => 7);
// 取得列的列表
foreach ($data as $key => $row) {
	$volume[$key]  = $row['volume'];
	$edition[$key] = $row['edition'];
}

// 将数据根据 volume 降序排列，根据 edition 升序排列
// 把 $data 作为最后一个参数，以通用键排序
array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);


//要进行不区分大小写的排序 ??
$array = array('Alpha', 'atomic', 'Beta', 'bank');
$array_lowercase = array_map('strtolower', $array);

print_r($array_lowercase);
array_multisort($array_lowercase, SORT_ASC, SORT_STRING, $array);

print_r($array);